@extends('Api.common.base')
@section('content')
    <link rel="stylesheet" href="/static/backend/css/login.css">
    <body class="beg-login-bg">
    <div class="beg-login-box" >
        <header>
            <h1>{{\App\Http\Controllers\PublicController::getHost()}}</h1>
        </header>
        <div class="beg-login-main">
            <form action="{{ URL::action('Api\LoginController@login')}}" class="layui-form" method="post">
                {{ csrf_field() }}
                <div class="layui-form-item">
                    <label class="beg-login-icon">
                        <i class="layui-icon">&#xe612;</i>
                    </label>
                    <input type="text" lay-verify="required" name="name" autocomplete="off" placeholder="这里输入账号" class="layui-input" lay-verType="tips">
                </div>
                <div class="layui-form-item">
                    <label class="beg-login-icon">
                        <i class="layui-icon">&#xe642;</i>
                    </label>
                    <input type="password" lay-verify="required" name="password" autocomplete="off" placeholder="这里输入密码" class="layui-input" lay-verType="tips">
                </div>
                {{--<div class="layui-form-item" style="position: relative">--}}
                {{--<label class="beg-login-icon">--}}
                {{--<i class="layui-icon">&#xe643;</i>--}}
                {{--</label>--}}
                {{--<input type="text" lay-verify="required" name="captcha" autocomplete="off" placeholder="验证码" class="layui-input" lay-verType="tips" style="width: 130px">--}}
                {{--<img src="{{url('api/Code?r='.time())}}" alt="验证码" width="120" class="pic" style="height:38px;cursor:pointer; position: absolute; right: 0; top: 0" onclick="this.src='{{url('api/Code?r=1')}}'+Math.random()"/>--}}
                {{--</div>--}}
                <div class="layui-form-item">
                    <div class="beg-pull">
                        <button type="submit" class="layui-btn layui-btn-normal" style="width:100%;" lay-submit lay-filter="formDemo">
                            登　　录
                        </button>
                    </div>
                </div>
            </form>
        </div>
        <footer>
        </footer>
    </div>
    <div style="background-color:white;height:80px;bottom: 0;position: absolute;width: 100%;text-align:center;line-height:80px;font-size:12px;color:#f44336;letter-spacing: 1px">
        推荐使用：谷歌浏览器 或 任何浏览器的极速模式进行访问
    </div>

    <script>
        $(function(){
            layui.use(['layer','form'], function(){
                var form = layui.form;
                var layer = layui.layer;

                //监听提交
                form.on('submit(formDemo)', function (data) {
                    var action = data.form.action;//表单提交URL地址
                    console.log(JSON.stringify(data.field));//表单数据
                    $.post(action, data.field, function (obj) {
                        //根据返回结果作出相应处理
                        if(obj.code != 200){
                            layer.msg(obj.msg,{anim:1,time:1000},function () {
                                // location.href = obj.url;
                            });
                        }else{
                            layer.msg(obj.msg,{anim: 4, time: 1000},function(){
                                location.href = obj.url;
                            })
                        }
                    });
                    return false;//注释掉这行代码后，表单将会以普通方式提交表单，否则以ajax方式提交表单
                });
            });
        })
    </script>

@endsection